package com.ruoyi.vehicle.service.impl;

import java.util.List;
import com.ruoyi.common.constant.VehicleConstants;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.vehicle.mapper.TVehicleInfoMapper;
import com.ruoyi.vehicle.domain.TVehicleInfo;
import com.ruoyi.vehicle.service.ITVehicleInfoService;

/**
 * 车辆信息Service业务层处理
 * 
 * @author wzy
 * @date 2024-10-12 20:41:53
 */
@Service
public class TVehicleInfoServiceImpl implements ITVehicleInfoService 
{
    @Autowired
    private TVehicleInfoMapper tVehicleInfoMapper;

    /**
     * 查询车辆信息
     * 
     * @param vehicleId 车辆信息主键
     * @return 车辆信息
     */
    @Override
    public TVehicleInfo selectTVehicleInfoByVehicleId(Long vehicleId)
    {
        return tVehicleInfoMapper.selectTVehicleInfoByVehicleId(vehicleId);
    }

    /**
     * 查询车辆信息列表
     * 
     * @param tVehicleInfo 车辆信息
     * @return 车辆信息
     */
    @Override
    public List<TVehicleInfo> selectTVehicleInfoList(TVehicleInfo tVehicleInfo)
    {
        return tVehicleInfoMapper.selectTVehicleInfoList(tVehicleInfo);
    }

    /**
     * 新增车辆信息
     * 
     * @param tVehicleInfo 车辆信息
     * @return 结果
     */
    @Override
    public int insertTVehicleInfo(TVehicleInfo tVehicleInfo)
    {
        tVehicleInfo.setCreateTime(DateUtils.getNowDate());
        return tVehicleInfoMapper.insertTVehicleInfo(tVehicleInfo);
    }

    /**
     * 修改车辆信息
     * 
     * @param tVehicleInfo 车辆信息
     * @return 结果
     */
    @Override
    public int updateTVehicleInfo(TVehicleInfo tVehicleInfo)
    {
        tVehicleInfo.setUpdateTime(DateUtils.getNowDate());
        return tVehicleInfoMapper.updateTVehicleInfo(tVehicleInfo);
    }

    /**
     * 批量删除车辆信息
     * 
     * @param vehicleIds 需要删除的车辆信息主键
     * @return 结果
     */
    @Override
    public int deleteTVehicleInfoByVehicleIds(Long[] vehicleIds)
    {
        return tVehicleInfoMapper.deleteTVehicleInfoByVehicleIds(vehicleIds);
    }

    /**
     * 删除车辆信息信息
     * 
     * @param vehicleId 车辆信息主键
     * @return 结果
     */
    @Override
    public int deleteTVehicleInfoByVehicleId(Long vehicleId)
    {
        return tVehicleInfoMapper.deleteTVehicleInfoByVehicleId(vehicleId);
    }

    /**
     * 校验车牌号码是否唯一
     *
     * @param tVehicleInfo 客户信息
     * @return 结果
     */
    @Override
    public String checkVehicleLicenseNumberUnique(TVehicleInfo tVehicleInfo)
    {
        Long vehicleId = StringUtils.isNull(tVehicleInfo.getVehicleId()) ? -1L : tVehicleInfo.getVehicleId();
        TVehicleInfo info = tVehicleInfoMapper.checkVehicleLicenseNumberUnique(tVehicleInfo.getVehicleLicenseNumber());
        if (StringUtils.isNotNull(info) && info.getVehicleId().longValue() != vehicleId.longValue())
        {
            return VehicleConstants.NOT_UNIQUE;
        }
        return VehicleConstants.UNIQUE;
    }

    /**
     * 查询车辆信息选项
     *
     * @param tVehicleInfo 车辆信息
     * @return 车辆信息集合
     */
    @Override
    public List<TVehicleInfo> selectTVehicleInfoAll(TVehicleInfo tVehicleInfo)
    {
        return tVehicleInfoMapper.selectTVehicleInfoAll(tVehicleInfo);
    }

}
